
local total = achievements.GetValue( "Party-Pooped", "total", 0 )

local function PlayerKilled( msg )
	local victim, inflictor, attacker = msg:ReadEntity(), msg:ReadString(), msg:ReadString()
	if ( total != 5 && victim == LocalPlayer() && inflictor == "gmod_balloon" ) then
		total = math.Clamp( total + 1, 0, 5 )
		achievements.Update( "Party-Pooped", total / 5, total .. "/5" )
		achievements.SetValue( "Party-Pooped", "total", total )
	end
	return victim, inflictor, attacker
end
usermessage.AddHook( "PlayerKilled", "Achievements.PartyPooped", PlayerKilled )

achievements.Register( "Party-Pooped", "Get killed five times by balloons.", "achievements/partypooped", total / 5, total .. "/5" )
